﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Web.Security;
using System.Configuration;
namespace Paradox.Reporting
{
    public class Error
    {
        //Class Locals
        private string _page, _message, _errorcode;
        
        //
        //Summary
        //  Logs a reported error to the error log in the database
        //
        // Parameters:
        //  _errorcode:
        //      a string that contains the errorcode of the error 
        // _message
        //      a string that contains a descriptive mssage about the error 
        // _page
        //      a string that contains the page or controller the error occurred 
        public Error()
        {
            this._page = "Unknown" ;
            this._message = "Unknown" ;
            this._errorcode = "Unknown";

        }


        public Error(string page, string message, string errorcode)
        {
            this._page = page;
            this._message = message;
            this._errorcode = errorcode;
        
        }

        public void sendError()
        {
          

            string from = "reporting@paradoxonline.net", to = "", subject = "", body = "" ;
            string[] admins = Roles.GetUsersInRole("admin");
            SmtpClient smtp = new SmtpClient("localhost");
            
            foreach (var user in admins)
            { 
            
            
            }

                
                
            //MailMessage m = new 

            MailMessage mail = new MailMessage(from,to, subject, body);
             
            //Summary
            //  Logs a reported error to the error log in the database
            //
            // Parameters:
            //  _errorcode:
            //      a string that contains the errorcode of the error 
            // 
            if (_errorcode != "404")
            { 
                   
            }

            ///<summary>
            //TODO: Reporting Logic 
            // - will add a record to the error log db
            // - will send an email to the administrators role group  
           ///</summary>          


        }

        //Getters
        public string getPage()
        {
            return _page;
        }

        public string getErrorCode()
        {
            return _errorcode;
        }

        public string getMessage()
        {
            return _message;
        }
        //Setters

        public void setPage(string page)
        {
            _page = page;
        }

        public void setErrorCode(string errorcode)
        {
            _errorcode = errorcode;
        }

        public void setMessage(string message)
        {
            _message = message;
        }
    }


   
}